//
//  HCStarViewController.m
//  HappyChildren
//
//  Created by WillyZhao on 2017/1/20.
//  Copyright © 2017年 WillyZhao. All rights reserved.
//

#import "HCStarViewController.h"

#import "HCStaredView.h"

#import "HCStarDidModel.h"

#import "HCLogViewController.h"

@interface HCStarViewController () <HCStaredViewStarDelegate> {
    HCStarDidModel *model;
    HCStaredView *sView;
}

@end

@implementation HCStarViewController

-(void)viewWillAppear:(BOOL)animated {
    [super viewWillAppear:animated];
   
    if ([PublicFunction isNull:HCGETUSER(@"userid")]) {

    }else{
        [self.dataRequest postHC_HomeStarDid:HCGETUSER(@"userid")];
    }
}

- (void)viewDidLoad {
    [super viewDidLoad];
    
    self.textTitle = @"育儿宝箱";
    sView = [[HCStaredView alloc] initWithFrame:CGRectMake(0, 0, self.centerView.frame.size.width, self.centerView.frame.size.height)];
    sView.delegate = self;
    [self.centerView addSubview:sView];
    self.dataRequest.delegate = self;
}

-(void)starViewClicked:(NSIndexPath *)indexPath {
    
    HCStarDidData *data = model.star[indexPath.row];
    [self pushChildrenViewController:@"HCStarDidViewController" parameterObject:data dataObject:nil];
}

-(void)dataRequesterFinish:(DataRequester *)requester requesterWithType:(DataRequestType)aType receiveDictionary:(NSDictionary *)dictionary {
    
    NSLog(@"星级评价:%@",dictionary);
    model = [[HCStarDidModel alloc] initWithDictionary:dictionary error:nil];
    sView.model = model;
    
}

-(void)dataRequesterFail:(DataRequester *)requester requesterWithType:(DataRequestType)aType receiveErrorDictionary:(NSDictionary *)dictionary {

    NSLog(@"星级评价网络请求失败");
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

@end
